package com.atos.smp.dao.impl;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.atos.smp.beans.Tool;
import com.atos.smp.beans.Process;
import com.atos.smp.beans.Rule;
import com.atos.smp.beans.Tool;
import com.atos.smp.dao.ToolDao;

public class ToolDaoImpl extends HibernateDaoSupport  implements ToolDao {

private List<Tool> Tools;
	
	public ToolDaoImpl() {
		Tools = new ArrayList<Tool>();
		
	}
	@Override
	public void save(Tool Tool) {
		getHibernateTemplate().persist(Tool);
	}

	@Override
	public void update(Tool Tool) {
		getHibernateTemplate().update(Tool);
	}

	@Override
	public void delete(Tool Tool) {
		getHibernateTemplate().delete(Tool);
	}

	@Override
	public Tool findToolById(int id) {
		
		@SuppressWarnings("unchecked")
		List<Tool> list = getHibernateTemplate().find("from Tool where id='"+id+"'");
		if(list != null &&  list.size()>0){
			return (Tool) list.get(0);
		}
		
		else
			return null;
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<Tool> findAllTools() {
		Tools = getHibernateTemplate().find("from Tool");
		return Tools;
	}
	
	
	
	
}
